package com.zhang.passer.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhang.passer.domain.UserDo;
import com.zhang.passer.mapper.UserMapper;
import com.zhang.passer.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("user")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<UserDo> queryAll(UserDo userDo) {
        QueryWrapper<UserDo> userDoQueryWrapper = new QueryWrapper<>(userDo);
        return userMapper.selectList(userDoQueryWrapper);
    }

    @Override
    public UserDo queryDetail(String username) {
        UserDo userDo = userMapper.selectOne(new QueryWrapper<>(new UserDo().setUsername(username)));
        return userDo;
    }

    @Override
    public Integer addUser(UserDo userDo) {
        return userMapper.insert(userDo);
    }
}
